﻿using System;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using dotnetOP.Data;
using Test;

namespace dotnetop_test
{
    class Program
    {
        static void Main(string[] args)
        {
            SqlGenerator wg = new SqlGenerator(ConfigurationManager.AppSettings["ConnectionString"]);
            wg.InitializeDatabase(typeof(EntityClass));
            foreach (string sql in wg.GetInitializationScripts(typeof(EntityClass)))
            {
                Console.WriteLine(sql);
            }

            ObjectAdapter oa = new ObjectAdapter(ConfigurationManager.AppSettings["ConnectionString"]);
            EntityClass ec = new EntityClass();
            ec.entityKey = 1;
            ec.nameEN = "en ...";
            ec.nameFR = "fr ...";
            ec.ord = 23;
            ec.lines = new EntityLine[] { new EntityLine(), new EntityLine() };
            ec.lines[0].line = "llll";
            ec.lines[1].line = "kkkk";
            ec.detail = new EntityDetail();
            ec.detail.startDate = DateTime.Now;
            ec.detail.content = "asdasdasd";

            oa.SaveObject(ec);

            Dictionary<string, object> param = new Dictionary<string, object>();
            param["nameEN"] = "en ...";

            dotnetOP.Base.DnopObject[] objs = oa.GetObject(param, typeof(EntityClass));

            //oa.DeleteObject(ec);

            EntityClass ec1 = (EntityClass)oa.GetObject(ec.ID, typeof(EntityClass));
        }
    }
}
